package com.wz.device.controller;


import com.wz.device.entity.BasDeviceRecord;
import com.wz.device.service.BasDeviceRecordService;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.framework.web.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qiqi
 * @since 2021-10-22
 */
@Controller
@RequestMapping("/device/basDeviceRecord")
public class BasDeviceRecordController extends BaseController {

    private String prefix = "device/basDeviceRecord";

    @Autowired
    private BasDeviceRecordService basDeviceRecordService;



//    @RequiresPermissions("device:basDeviceRecord:view")
    @GetMapping()
    public String user() {
        return prefix + "/basDeviceRecord";
    }

    /**
     * 设备履历记录列表
     * @param basDeviceRecord
     * @return
     */
//    @RequiresPermissions("device:basDeviceRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasDeviceRecord basDeviceRecord){
        startPage();
        List<BasDeviceRecord> list = basDeviceRecordService.selectBasDeviceRecordList(basDeviceRecord);
        return getDataTable(list);
    }


    /**
     * 新增设备履历记录信息
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        return prefix + "/add";
    }

    /**
     * 设备履历记录增加
     * @param basDeviceRecord
     * @return
     */
    @RequiresPermissions("device:basDeviceRecord:add")
    @Log(title = "设备管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated BasDeviceRecord basDeviceRecord)
    {
        return toAjax(basDeviceRecordService.insertBasDeviceRecord(basDeviceRecord));
    }

    /**
     * 修改设备履历记录信息
     */
    @RequiresPermissions("device:basDeviceRecord:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        mmap.put("basDeviceRecord", basDeviceRecordService.selectBasDeviceRecord(id));
        return prefix + "/edit";
    }

    /**
     * 修改保存设备履历记录信息
     */
    @RequiresPermissions("device:basDeviceRecord:edit")
    @Log(title = "设备履历管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@Validated BasDeviceRecord basDeviceRecord)
    {
        return toAjax(basDeviceRecordService.updateBasDeviceRecord(basDeviceRecord));

    }


    @RequiresPermissions("device:basDeviceRecord:remove")
    @Log(title = "设备履历记录管理", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basDeviceRecordService.deleteBasDeviceRecordByIds(ids));
    }





}
